﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace Toolbox.ZoomList
{
    public class ZoomList<T> : IZoomItem, IList<T>, ICloneable where T : IZoomItem
    {
        [Obsolete()]
        public int SizeX { get; internal set; }
        [Obsolete()]
        public int SizeY { get; internal set; }

        
        #region Zone helpers

         [Obsolete]
        public bool Contain(int x, int y)
        {
            return false;
        }

        [Obsolete]
        public bool Contain(params object[] args)
        {
            return false;
        }

        [Obsolete]
        public T Get(int x, int y)
        {
            return default(T);
        }

        [Obsolete]
        public T Get(params object[] args)
        {
            return default(T);
        }

        [Obsolete]
        public T Init(params object[] args)
        {
            return default(T);
        }

        #endregion

        #region IZoomItem Members

        public int X { get; internal set; }
        public int Y { get; internal set; }

        #endregion

        public T Reference { get; private set; }

        public ZoomList(T Reference)
        {
            this.X = 0;
            this.Y = 0;
            this.Reference = Reference;
            this.TElements = new List<T>(new T[] { Reference });
        }

        public ZoomList(int x, int y, T Reference)
        {
            this.X = x;
            this.Y = y;
            this.Reference = Reference;
            this.TElements = new List<T>(new T[] { Reference });
        }

        #region IList<T> Members

        private List<T> TElements;

        public int IndexOf(T item)
        {
            return this.TElements.IndexOf(item);
        }

        public void Insert(int index, T item)
        {
            this.TElements.Insert(index, item);
        }

        public void RemoveAt(int index)
        {
            this.TElements.RemoveAt(index);
        }

        public T this[int index]
        {
            get { return this.TElements[index]; }
            set { this.TElements[index] = value; }
        }

        public T this[int x, int y]
        {
            get
            {
                throw new IndexOutOfRangeException();
            }
        }

        #endregion

        #region ICollection<T> Members

        public void Add(T item)
        {
            this.TElements.Add(item);
        }

        public void Clear()
        {
            this.TElements.Clear();
        }

        public bool Contains(T item)
        {
            return this.TElements.Contains(item);
        }

        public void CopyTo(T[] array, int arrayIndex)
        {
            this.TElements.CopyTo(array, arrayIndex);
        }

        public int Count
        {
            get { return this.TElements.Count; }
        }

        public bool IsReadOnly
        {
            get { return false; }
        }

        public bool Remove(T item)
        {
            return this.TElements.Remove(item);
        }

        #endregion

        #region IEnumerable<T> Members

        public IEnumerator<T> GetEnumerator()
        {
            return this.TElements.GetEnumerator();
        }

        #endregion

        #region IEnumerable Members

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return this.TElements.GetEnumerator();
        }

        #endregion

        #region ICloneable Members

        public virtual object Clone()
        {
            return base.MemberwiseClone();
        }

        #endregion
    }
}
